package com.ly.consumer.config.opfegin.handler;


import feign.RequestInterceptor;
import feign.RequestTemplate;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;

//自定义实现拦截器
public class OpfeginHandler implements RequestInterceptor {


    @Override
    public void apply(RequestTemplate requestTemplate) {
        //从request的上下文中拿出header
        //干点啥都行
       ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
       HttpServletRequest request = attributes.getRequest();
       requestTemplate.header("Token",request.getHeader("Token"));
    }
}
